package moodish.server;

import java.util.LinkedList;

import moodish.comm.ServerComm;
import moodish.comm.ServerSideMessage;

public class ServerTester implements ServerComm {


	LinkedList<ServerSideMessage> messageList = new LinkedList<ServerSideMessage>();   
	public void addMessage(ServerSideMessage message){
		messageList.add(message);
	}
	@Override
	public void start() {
	
    //connect
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "Bruno"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "Ana"));		
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "Goncalo"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "SLB87"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "SCP87"));
	//friendship
	messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Ana", "Bruno"));
	messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Ana", "Bruno"));
	messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Bruno", "Ana"));
	messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Goncalo", "Bruno"));
	messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Bruno", "SLB87"));
	messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Goncalo", "SCP87"));
	//mood message
	messageList.add(new Message(ServerSideMessage.Type.MOODISH_MESSAGE, "Annoyed", "Bruno"));
	//unfriendship
	messageList.add(new Message(ServerSideMessage.Type.UNFRIENDSHIP, "Bruno", "Ana"));
	messageList.add(new Message(ServerSideMessage.Type.UNFRIENDSHIP, "Bruno", "SCP87"));
	//disconnect
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "Bruno"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "Ana"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "Goncalo"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "SLB87"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "SCP87"));
	
	}
	@Override
	public ServerSideMessage getNextMessage() {
		ServerSideMessage message = messageList.removeFirst();
		return  message;
	}
	@Override
	public boolean hasNextMessage() {
		if(messageList.isEmpty()){
			return false;
		}
		return true;
	}
	@Override
	public void sendMoodishMessage(String fromNickname, String toNickname,
			String moodishMessage) {
		System.out.println("Tester Moodish From: " + fromNickname + " To: " + toNickname + " Moodish: " + moodishMessage);
		
	}
	@Override
	public void sendNewFriendship(String toNickname, String newFriendship) {
		System.out.println("Tester  Friendship " + toNickname + " has new friend: " + newFriendship);
		
	}
	@Override
	public void sendNewUnfriendship(String toNickname, String unfriendship) {
		System.out.println("Tester  UnFriendship " + toNickname + " lost a friend " + unfriendship);
		
	}
	@Override
	public void sendError(String toNickname, String error) {
		System.out.println("Tester  Error to Client " + toNickname + "  Message: " + error );
		
	}
	@Override
	public void sendClientConnected(String toNickname, String connectedNickname) {
		System.out.println("Tester Client: " + toNickname + " ClientConnected: " + connectedNickname);
		
	}
	@Override
	public void sendClientDisconnected(String toNickname,
			String disconnectedNickname) {
		System.out.println("Tester  Client: " + toNickname + " ClientDisconnected: " + disconnectedNickname);
		
	}
	@Override
	public boolean clientIsConnected(String nickname) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public void disconnectClient(String nickname) {
		System.out.println("Tester  Client: " + nickname + "disconnected" );
		
	}
	
	
	
	
}
